package cn.dglydrpy.study.ssm.utils;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 * 自定义标签
 * @author LY_飘涯
 *
 */
public class DateTagUtils extends SimpleTagSupport {
	private String format;
	private Date dateTime;
	

	public void setFormat(String format) {
		this.format = format;
	}
    public void setDateTime(Date dateTime) {
		this.dateTime = dateTime;
	}


	@Override
	public void doTag() throws JspException, IOException {
		PageContext pc =(PageContext) getJspContext();
		
		JspWriter out = pc.getOut();
		
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		
		out.println(sdf.format(dateTime));
	
	}

}
